package com.example.demo.Mapper;

import com.example.demo.Entity.WorkExperience;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WorkExperienceMapper {
    @Select("SELECT * FROM work_experience WHERE person_id = #{userId}")
    List<WorkExperience> findByUserId(Long userId);

    void batchUpdateWorkExperiences(@Param("experiences") List<WorkExperience> experiences);

    // 删除指定用户的所有工作经历
    @Delete("DELETE FROM work_experience WHERE person_id = #{userId}")
    int deleteByUserId(Long userId);

    // 删除单个工作经历
    @Delete("DELETE FROM work_experience WHERE id = #{id}")
    int deleteById(Long id);

    // 插入工作经历
    @Insert("INSERT INTO work_experience(person_id, company_name, job_title, start_date, end_date, description) " +
            "VALUES(#{person_id}, #{company_name}, #{job_title}, #{start_date}, #{end_date}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(WorkExperience experience);
}
